var _common_util = require('util/common_util.js');

var _user_service = {

    // checkLogin : function (resolve, reject){
    //     _common_util.request({
    //         url     :   _common_util.getServerURL(''),
    //         method  :   'POST',
    //         success :   resolve,
    //         error   :   reject
    //     });
    // },

    logout : function (resolve, reject){
        _common_util.request({
            url     :   _common_util.getServerURL('/user/logout'),
            method  :   'POST',
            success :   resolve,
            error   :   reject
        });
    },

    login : function (userInfo, resolve, reject){
        _common_util.request({
            url     :   _common_util.getServerURL('/user/login'),
            data    :   userInfo,
            method  :   'POST',
            success :   resolve,
            error   :   reject
        });
    },

    register : function (userInfo, resolve, reject){
        _common_util.request({
            url     :   _common_util.getServerURL('/user/register'),
            data    :   userInfo,
            method  :   'POST',
            success :   resolve,
            error   :   reject
        });
    },

     // 获取用户信息
     getUserInfo : function(resolve, reject){
        _common_util.request({
            url     : _common_util.getServerURL('/user/get_user_info'),
            data    :   {
                userID  : sessionStorage.getItem('user_id')
                // userID  : _common_util.getCookie("user_id")
            },
            method  : 'GET',
            success : resolve,
            error   : reject
        });
    },

    //修改密码
    updatePassword  : function(data, resolve, reject){
        _common_util.request({
            url     : _common_util.getServerURL('/user/reset_password'),
            data    :  data,
            method  : 'GET',
            success : resolve,
            error   : reject
        });
    },

    //修改密码
    // getQuestion  : function(data, resolve, reject){
    //     _common_util.request({
    //         url     : _common_util.getServerURL('/user/reset_password'),
    //         data    :  data,
    //         method  : 'GET',
    //         success : resolve,
    //         error   : reject
    //     });
    // }
}

module.exports = _user_service;